from enum import Enum
from typing import List


class GridInfo(object):
    def __init__(self, price: float, percent: float = 0, batch: int = 0, money: float = 0, fundCnt: int = 0, sellPrice: float = 0, earning: float = 0, earningRate: float = 0):
        self.price = price
        self.percent = percent
        self.batch = batch
        self.money = money
        self.fundCnt = fundCnt
        self.sellPrice = sellPrice
        self.earning = earning
        self.earningRate = earningRate


    def to_dict(self):
        return {
            "价格": self.price,
            "回撤": self.percent,
            "批次": self.batch,
            "数量": self.fundCnt,
            "金额": self.money,
            "卖出价格": self.sellPrice,
            "收益": self.earning,
            "收益率%": self.earningRate,
        }


# 定义市场枚举类
class Market(Enum):
    A = "A"     # A股
    H = "H"     # 港股

# ETF基金信息
class ETFFundInfo(object):
    def __init__(self, code: str, name: str):
        self.code = code
        self.name = name

# 股票指数信息
class StockIndexInfo(object):
    def __init__(self, code: str, name: str, fundList: List[ETFFundInfo] = [], market: Market = Market.A):
        self.code = code
        self.name = name
        self.market = market
        self.fundList = fundList


def get_shang_zheng50_index_info() -> StockIndexInfo:
    return StockIndexInfo(
        code="000016",
        name="上证50",
        fundList=[
            ETFFundInfo(code="510050", name="上证50ETF易方达"),
            ETFFundInfo(code="510100", name="上证50ETF易方达"),
        ],
        market=Market.A
    )

def get_hu_shen300_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="000300",
        name="沪深300",
        fundList=[
            ETFFundInfo(code="510310", name="沪深300ETF易方达"),
            ETFFundInfo(code="510330", name="沪深300ETF华夏"),
            ETFFundInfo(code="510300", name="沪深300ETF"),
            ETFFundInfo(code="159925", name="沪深300ETF南方"),
        ],
        market=Market.A
    )

# #############################################
def GetZhongZhengHongLiIndexInfo() -> StockIndexInfo:
    return StockIndexInfo(
        code="000922",
        name="中证红利",
        fundList=[
            ETFFundInfo(code="515180", name="红利ETF易方达"),
            ETFFundInfo(code="515080", name="中证红利ETF"),

        ],
        market=Market.A
    )
def GetHSKeJiStockIndexInfo() -> StockIndexInfo:
    return StockIndexInfo(
        code="HSTECH",
        name="恒生科技指数",
        fundList=[
            ETFFundInfo(code="513130", name="恒生科技ETF"),
            ETFFundInfo(code="513180", name="恒生科技指数ETF"),
            ETFFundInfo(code="513010", name="恒生科技30ETF"),
            ETFFundInfo(code="159740", name="恒生科技ETF"),
            ETFFundInfo(code="513380", name="恒生科技ETF龙头"),

        ],
        market=Market.H
    )
def get_heng_sheng_stock_index_info() -> StockIndexInfo:
    return StockIndexInfo(
        code="HSI",
        name="恒生指数",
        fundList=[
            ETFFundInfo(code="159920", name="恒生ETF"),
        ],
        market=Market.H
    )


def GetHSYiLiaoStockIndexInfo() -> StockIndexInfo:
    return StockIndexInfo(
        code="HSHCI",
        name="恒生医疗保健",
        fundList=[
            ETFFundInfo(code="513060", name="恒生医疗ETF"),
        ],
        market=Market.H
    )


# 获取半导体指数信息
def get_ban_dao_ti_stock_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="H30184",
        name="中证全指半导体",
        fundList=[
            ETFFundInfo(code="512480", name="半导体ETF")
        ],
        market=Market.A
    )


def GetChuangYeBanStockIndexInfo() -> StockIndexInfo:

    return StockIndexInfo(
        code="399006",
        name="创业板指",
        fundList=[
            ETFFundInfo(code="159915", name="创业板ETF"),
            ETFFundInfo(code="159952", name="创业板ETF广发"),
            ETFFundInfo(code="159977", name="创业板ETF天弘"),
        ],
        market=Market.A
    )

def get_chuang_ye_ban_stock_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="399006",
        name="创业板指",
        fundList=[
            ETFFundInfo(code="159915", name="创业板ETF"),
        ],
        market=Market.A
    )

def get_bai_jiu_stock_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="399997",
        name="中证白酒",
        fundList=[
            ETFFundInfo(code="161725", name="白酒基金LOF"),
        ],
        market=Market.A
    )


def GetLvYouIndexInfo() -> StockIndexInfo:

    return StockIndexInfo(
        code="930633",
        name="中证旅游",
        fundList=[
            ETFFundInfo(code="159766", name="旅游ETF"),
            ETFFundInfo(code="562510", name="旅游ETF"),
        ],
        market=Market.A
    )

def GetYouXiIndexInfo() -> StockIndexInfo:

    return StockIndexInfo(
        code="930901",
        name="动漫游戏",
        fundList=[
            ETFFundInfo(code="516010", name="游戏ETF"),
            ETFFundInfo(code="159869", name="游戏ETF"),
        ],
        market=Market.A
    )
def get_zhong_zheng500_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="000905",
        name="中证500",
        fundList=[
            ETFFundInfo(code="510500", name="中证500ETF"),
            ETFFundInfo(code="512500", name="中证500ETF华夏"),
            ETFFundInfo(code="159922", name="中证500ETF"),
            ETFFundInfo(code="510510", name="中证500ETF基金"),
            ETFFundInfo(code="510580", name="中证500ETF易方达"),
        ],
        market=Market.A
    )

def GetGuangFuIndexInfo() -> StockIndexInfo:

    return StockIndexInfo(
        code="931151",
        name="光伏产业",
        fundList=[
            ETFFundInfo(code="159857", name="光伏ETF"),
            ETFFundInfo(code="515790", name="光伏ETF"),
        ],
        market=Market.A
    )

def get_huan_bao_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="000827",
        name="中证环保",
        fundList=[
            ETFFundInfo(code="512580", name="环保ETF"),
        ],
        market=Market.A
    )
def GetZhongYaoIndexInfo() -> StockIndexInfo:
    return StockIndexInfo(
        code="930641",
        name="中证中药",
        fundList=[
            ETFFundInfo(code="159647", name="中药ETF"),
            ETFFundInfo(code="560080", name="中药ETF"),
        ],
        market=Market.A
    )
def get_yi_yao_wei_sheng_index_info() -> StockIndexInfo:
    return StockIndexInfo(
        code="000991",
        name="全指医药",
        fundList=[
            ETFFundInfo(code="159938", name="医药卫生ETF"),
        ],
        market=Market.A
    )





def get_ji_jian_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="930608",
        name="中证基建",
        fundList=[
            ETFFundInfo(code="516950", name="基建ETF"),
        ],
        market=Market.A
    )
def ShangZheng50IndexInfo() -> StockIndexInfo:

    return StockIndexInfo(
        code="000016",
        name="上证50",
        fundList=[
            ETFFundInfo(code="510050", name="上证50ETF"),
        ],
        market=Market.A
    )
def GetMeiTanIndexInfo() -> StockIndexInfo:

    return StockIndexInfo(
        code="399998",
        name="中证煤炭",
        fundList=[
            ETFFundInfo(code="515220", name="煤炭ETF"),
        ],
        market=Market.A
    )
def get_chuan_mei_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="399971",
        name="中证传媒",
        fundList=[
            ETFFundInfo(code="512980", name="传媒ETF"),
        ],
        market=Market.A
    )
def get_zhong_zheng_yi_liao_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="399989",
        name="中证医疗",
        fundList=[
            ETFFundInfo(code="512170", name="医疗ETF"),
        ],
        market=Market.A
    )
def get_quan_zhi_xin_xi_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="000993",
        name="全指信息",
        fundList=[
            ETFFundInfo(code="159939", name="信息技术ETF"),
        ],
        market=Market.A
    )
def GetJiaoYuIndexInfo() -> StockIndexInfo:

    return StockIndexInfo(
        code="931456",
        name="中国教育",
        fundList=[
            ETFFundInfo(code="513360", name="教育ETF"),
        ],
        market=Market.A
    )

def GetXuMuIndexInfo() -> StockIndexInfo:

    return StockIndexInfo(
        code="930707",
        name="中证畜牧",
        fundList=[
            ETFFundInfo(code="159867", name="畜牧ETF"),
        ],
        market=Market.A
    )
def GetZhengQuanIndexInfo() -> StockIndexInfo:

    return StockIndexInfo(
        code="399975",
        name="全指证券",
        fundList=[
            ETFFundInfo(code="159841", name="证券ETF"),
        ],
        market=Market.A
    )
def get_zhong_gai_hu_lian_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="H30533",
        name="中概互联",
        fundList=[
            ETFFundInfo(code="513050", name="中概互联网ETF"),
        ],
        market=Market.A
    )
def get_zheng_quan_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="399975",
        name="全指证券",
        fundList=[
            ETFFundInfo(code="512880", name="证券ETF"),
        ],
        market=Market.A
    )
def get_xiao_fei_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="000932",
        name="中证消费",
        fundList=[
            ETFFundInfo(code="159928", name="消费ETF"),
        ],
        market=Market.A
    )

def get_jun_gong_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="399967",
        name="中证军工",
        fundList=[
            ETFFundInfo(code="512680", name="军工ETF龙头"),
            ETFFundInfo(code="512660", name="军工ETF"),
        ],
        market=Market.A
    )
def get_zhong_zheng_xiao_fei_index_info() -> StockIndexInfo:

    return StockIndexInfo(
        code="000932",
        name="中证消费",
        fundList=[
            ETFFundInfo(code="159928", name="消费ETF"),
        ],
        market=Market.A
    )